<html>
<head><meta charset="utf-8"><title>get span of file from name · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html">get span of file from name</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229602941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229602941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229602941">(Mar 10 2021 at 04:46)</a>:</h4>
<p>How can I get the <code>Span</code> of a source file from its name? (For context, this is for use in rustdoc.)</p>



<a name="229603002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603002">(Mar 10 2021 at 04:47)</a>:</h4>
<p>you mean the filename? I don't think you can get the span from that alone</p>



<a name="229603095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603095">(Mar 10 2021 at 04:49)</a>:</h4>
<p>do you have any other info available?</p>



<a name="229603230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603230">(Mar 10 2021 at 04:51)</a>:</h4>
<p>Nope, I don't think so.</p>



<a name="229603237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603237">(Mar 10 2021 at 04:51)</a>:</h4>
<p>this is probably not possible then</p>



<a name="229603241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603241">(Mar 10 2021 at 04:51)</a>:</h4>
<p>how do you only have the filename? that seems odd</p>



<a name="229603329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603329">(Mar 10 2021 at 04:52)</a>:</h4>
<p>Welcome to rustdoc <span aria-label="wink" class="emoji emoji-1f609" role="img" title="wink">:wink:</span></p>



<a name="229603340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603340">(Mar 10 2021 at 04:53)</a>:</h4>
<p>In this case it makes sense because it's for <code>html/sources.rs</code>.</p>



<a name="229603418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603418">(Mar 10 2021 at 04:54)</a>:</h4>
<p>Oops, missed that the span is actually available <span aria-label="face palm" class="emoji emoji-1f926" role="img" title="face palm">:face_palm:</span></p>



<a name="229603436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603436">(Mar 10 2021 at 04:54)</a>:</h4>
<p>I do think it would be possible to add a <code>FileName -&gt; Span</code> function though.</p>



<a name="229603563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603563">(Mar 10 2021 at 04:56)</a>:</h4>
<p>Sorry for the noise, I think I got confused because the span on <code>clean::Item</code> is called <code>source</code>, I think because it used to be stringified.</p>



<a name="229603704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603704">(Mar 10 2021 at 04:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="307537">Camelid</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/get.20span.20of.20file.20from.20name/near/229603563">said</a>:</p>
<blockquote>
<p>Sorry for the noise, I think I got confused because the span on <code>clean::Item</code> is called <code>source</code>, I think because it used to be stringified.</p>
</blockquote>
<p>oh I thought I renamed that</p>



<a name="229603729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603729">(Mar 10 2021 at 04:59)</a>:</h4>
<p>if you want to make a PR changing it to <code>span</code> I'd love that :)</p>



<a name="229603737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/get%20span%20of%20file%20from%20name/near/229603737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/get.20span.20of.20file.20from.20name.html#229603737">(Mar 10 2021 at 04:59)</a>:</h4>
<p>I was right in the middle of renaming that when I got your message :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>